package com.apps.essentials;

import android.annotation.SuppressLint;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.json.JSONObject;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;

@SuppressLint("UseValueOf")
public class ConsumeWebService {
	
	  	private static String NAMESPACE = "http://webservices.com/";
	    private static String URL = "http://env-5553470.jelastic.servint.net/WebService/PropertyPortalWS?wsdl";
	    private static String SOAP_ACTION1 = "http://webservice.com/insert";
	    private static String SOAP_ACTION2 = "http://webservice.com/login";
	    private static String METHOD_NAME1 = "insert";
	    private static String METHOD_NAME2 = "login";
	    //add PROPERTY
	    private static String SOAP_ACTION_ADDPROPERTY = "http://webservice.com/addproperty";
	    private static String METHOD_NAME_ADDPROPERTY = "addproperty";
	    
	  //edit PROPERTY
	    private static String SOAP_ACTION_EDITPROPERTY = "http://webservice.com/updateproperty";
	    private static String METHOD_NAME_EDITPROPERTY = "updateproperty";
	    
	  //edit PROPERTY
	    private static String SOAP_ACTION_ADDAMMENITIES = "http://webservice.com/addammenities";
	    private static String METHOD_NAME_ADDAMMENITIES = "addammenities";
	    
	  //edit PROPERTY
	    private static String SOAP_ACTION_ADDPANORAMA = "http://webservice.com/addpanorama";
	    private static String METHOD_NAME_ADDPANORAMA = "addpanorama";
	    
	    //edit PROPERTY
	    private static String SOAP_ACTION_GETPANORAMA = "http://webservice.com/getpanorama";
	    private static String METHOD_NAME_GETPANORAMA = "getpanorama";
	    
	    //Retrieve by ID
	    private static String SOAP_ACTION_GETID = "http://webservice.com/getPersonId";
	    private static String METHOD_NAME_GETID = "getPersonId";
	    //Add Lead
	    private static String SOAP_ACTION_LEAD = "http://webservice.com/addlead";
	    private static String METHOD_NAME_LEAD = "addlead";
	    
	    private static String SOAP_ACTION_EDITLEAD = "http://webservice.com/editlead";
	    private static String METHOD_NAME_EDITLEAD = "editlead";
	    
	    private static String SOAP_ACTION_SAVELEAD = "http://webservice.com/saveorupdate";
	    private static String METHOD_NAME_SAVELEAD = "saveorupdate";
	    //Return all person
	    private static String SOAP_ACTION_ALLPERSON = "http://webservice.com/getAllPerson";
	    private static String METHOD_NAME_ALLPERSON = "getAllPerson";
	    //Return all property
	    private static String SOAP_ACTION_ALLPROPERTY = "http://webservice.com/getAllProperty";
	    private static String METHOD_NAME_ALLPROPERTY = "getAllProperty";
	    
	    //Udate person
	    private static String SOAP_ACTION_UPDATEPERSON = "http://webservice.com/update";
	    private static String METHOD_NAME_UPDATEPERSON = "update";
	    
	    //Delete person
	    private static String SOAP_ACTION_DELETEPERSON = "http://webservice.com/delete";
	    private static String METHOD_NAME_DELETEPERSON = "delete";
	    
	  //getPerson Type person
	    private static String SOAP_ACTION_GETPERSONTYPE = "http://webservice.com/getPersonType";
	    private static String METHOD_NAME_GETPERSONTYPE = "getPersonType";
	    	    
	  //getPerson Type person
	    private static String SOAP_ACTION_GETAGENTPROPERTY = "http://webservice.com/getagentproperty";
	    private static String METHOD_NAME_GETAGENTPROPERTY = "getagentproperty";
	    
	    private static String SOAP_ACTION_GETAGENTLEAD = "http://webservice.com/getagentlead";
	    private static String METHOD_NAME_GETAGENTLEAD = "getagentlead";
	    
	    private static String SOAP_ACTION_GETLEADPROPERTY = "http://webservice.com/getleadproperty";
	    private static String METHOD_NAME_GETLEADPROPERTY = "getleadproperty";
	    
	    private static String SOAP_ACTION_GETSOLDPROPERTY = "http://webservice.com/getsoldproperty";
	    private static String METHOD_NAME_GETSOLDPROPERTY = "getsoldproperty";
	    
	    private static String SOAP_ACTION_GETAMMENITIES = "http://webservice.com/getammenities";
	    private static String METHOD_NAME_GETAMMENITIES = "getammenities";
	    
	    private static String SOAP_ACTION_GETMYACCOUNT = "http://webservice.com/myaccount";
	    private static String METHOD_NAME_GETMYACCOUNT = "myaccount";
	    
	    private static String SOAP_ACTION_GETGRAPHDATA = "http://webservice.com/graphdata";
	    private static String METHOD_NAME_GETGRAPHDATA = "graphdata";
	    
	    private static String SOAP_ACTION_SEARCH = "http://webservice.com/multicriteriasearch";
	    private static String METHOD_NAME_SEARCH = "multicriteriasearch";
	    
	    
	    private static String SOAP_ACTION_GETPROPERTYBYSELLINGTYPE = "http://webservice.com/getAllPropertySellingType";
	    private static String METHOD_NAME_GETPROPERTYBYSELLINGTYPE = "getAllPropertySellingType";
	    
	    private static String SOAP_ACTION_GETSEARCH = "http://webservice/getAllType";
	    private static String METHOD_NAME_GETSEARCH = "getAllType";
	    
	    private static String SOAP_ACTION_GETSEARCHPRICE = "http://webservice/getAllPrice";
	    private static String METHOD_NAME_GETSEARCHPRICE = "getAllPrice";
	    
	    private static String SOAP_ACTION_GETSEARCHADDRESS = "http://webservice/getAllAddress";
	    private static String METHOD_NAME_GETSEARCHADDRESS = "getAllAddress";
	    
	    private static String SOAP_ACTION_GETSEARCHADDRESSANDTYPE = "http://webservice/getAddressAndType";
	    private static String METHOD_NAME_GETSEARCHADDRESSANDTYPE = "getAddressAndType";
	    
	    private static String SOAP_ACTION_GETSEARCHADDRESSANDPRICE = "http://webservice/getAddressAndPrice";
	    private static String METHOD_NAME_GETSEARCHADDRESSANDPRICE = "getAddressAndPrice";
	    
	    private static String SOAP_ACTION_GETSEARCHPRICEANDTYPE = "http://webservice/getPriceAndType";
	    private static String METHOD_NAME_GETSEARCHPRICEANDTYPE = "getPriceAndType";
	    
	    private static String SOAP_ACTION_GETSEARCHCATEGORY = "http://webservice/searchByCategory";
	    private static String METHOD_NAME_GETSEARCHCATEGORY = "searchByCategory";
	    private static String messa;
	    
	    private static String SOAP_ACTION_GETALLPROPERTYBYID = "http://webservice/getAllPropertyById";
	    private static String METHOD_NAME_GETALLPROPERTYBYID = "getAllPropertyById";

	    public boolean CreateAccount(String fname, String lname, String uname,
	            String password, String email, String mobile, String landLine,
	            String birthday, String type, String image) {


	        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);

	        request.addProperty("fname", fname);
	        request.addProperty("lname", lname);
	        request.addProperty("uname", uname);
	        request.addProperty("pwd", password);
	        request.addProperty("e_add", email);
	        request.addProperty("mobile", mobile);
	        request.addProperty("landLine", landLine);
	        request.addProperty("bday", birthday);
	        request.addProperty("type", type);
	        request.addProperty("image", image);

	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {
	        	

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION1, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();

	            if (response != null) {

	                if (response.toString().equals("true")) {
	                    System.out.println("Successfully Created");
	                } else {
	                    
	                    return false;
	                }
	            } else {
	                System.out.println("No Response");
	            }

	        } catch (Exception e) {
	            e.printStackTrace();
	            System.out.println("wala ne sud dri");
	            return false;
	        }
	        return true;
	    }
	    
	    public boolean updatePerson(String fname, String lname, String uname,
	            String password, String email, String mobile, String landLine,
	            String birthday, String type, String image, int id) {


	        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_UPDATEPERSON);

	        request.addProperty("fname", fname);
	        request.addProperty("lname", lname);
	        request.addProperty("uname", uname);
	        request.addProperty("pwd", password);
	        request.addProperty("e_add", email);
	        request.addProperty("mobile", mobile);
	        request.addProperty("landLine", landLine);
	        request.addProperty("bday", birthday);
	        request.addProperty("type", type);
	        request.addProperty("image", image);
	        request.addProperty("id", id);

	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {
	        	

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_UPDATEPERSON, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
	            if (response != null) {

	                if (response.toString().equals("true")) {
	                    System.out.println("Successfully Created");
	                } else {
	                    
	                    return false;
	                }
	            } else {
	                System.out.println("No Response");
	            }
	            

	        } catch (Exception e) {
	            e.printStackTrace();
	            System.out.println("wala ne update");
	            return false;
	        }
	        return true;
	    }
	    public void deletePerson(int id) {


	        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_DELETEPERSON);

	        request.addProperty("id", id);

	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {
	        	

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_DELETEPERSON, envelope);


	        } catch (Exception e) {
	            e.printStackTrace();
	            System.out.println("wala nA DELETE");
	        }
	    }
	    public String getMessageLogIn(String mess){
	    	return messa = mess;
	    }
	    public boolean Login(String username, String password) {
	    	
	        try {
	            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME2);
	            request.addProperty("username", username);
	            request.addProperty("password", password);

	            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	            envelope.setOutputSoapObject(request);

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION2, envelope);
	            // Get the SoapResult from the envelope body.
	            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();

	            if (response != null) {

	                if (response.toString().equals("true")) {
	                    System.out.println("Successfully login"+response.toString());
	                    return true;
	                    
	                } else {
	                    System.out.println("Not match!"+response.toString());	                    
	                    return false;
	                }
	            } else {
	                System.out.println("No Response");
	            }
	        } catch (IOException ex) {
	            Logger.getLogger(ConsumeWebService.class.getName()).log(Level.SEVERE, null, ex);
	        } catch (XmlPullParserException ex) {
	            Logger.getLogger(ConsumeWebService.class.getName()).log(Level.SEVERE, null, ex);
	        }
	        return true;
	    }
	    public String PersonType(String username) {
	    	String result=null;
	        try {
	            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETPERSONTYPE);
	            request.addProperty("username", username);
	           
	            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	            envelope.setOutputSoapObject(request);

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_GETPERSONTYPE, envelope);
	            // Get the SoapResult from the envelope body.
	            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();

	            if (response != null) {
	            	result=response.toString();
	            	System.out.println(result);
	            	
	            } else {
	                System.out.println("No Response");
	            }
	        } catch (IOException ex) {
	            Logger.getLogger(ConsumeWebService.class.getName()).log(Level.SEVERE, null, ex);
	        } catch (XmlPullParserException ex) {
	            Logger.getLogger(ConsumeWebService.class.getName()).log(Level.SEVERE, null, ex);
	        }
	        return result;
	    }

	    public boolean AddProperty(String pname,
	            String address,
	            String price,
	            String description,
	            String longitude,
	            String latitude,
	            int person_id,
	            String type, 
	            String status, 
	            String image,
	            String selling_type,String ammenities_url,String ammenities_description,String panorama_url) {


	        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_ADDPROPERTY);

	        request.addProperty("pname", pname);
	        request.addProperty("address", address);
	        request.addProperty("description", description);
	        request.addProperty("price", price);
	        request.addProperty("lat", latitude);
	        request.addProperty("lon", longitude);
	        request.addProperty("id", person_id);
	        request.addProperty("type", type);
	        request.addProperty("status", status);
	        request.addProperty("image", image);
	        request.addProperty("selling_type", selling_type);
	        request.addProperty("ammenities_url", ammenities_url);
	        request.addProperty("ammenities_description", ammenities_description);
	        request.addProperty("panorama_url", panorama_url);

	        //request.addProperty("image", image);

	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_ADDPROPERTY, envelope);
	            return true;

	        } catch (Exception e) {
	            e.printStackTrace();
	            System.out.println("wala ne sud dri");
	            return false;
	        }
			
	    }
	    public boolean EditProperty(String pname,
	            String address,
	            String price,
	            String description,
	            String longitude,
	            String latitude,
	            int person_id,
	            String type, 
	            String status, 
	            String image,
	            int property_id,
	            String sold_date,
	            String selling_type) {


	        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_EDITPROPERTY);

	        request.addProperty("pname", pname);
	        request.addProperty("address", address);
	        request.addProperty("description", description);
	        request.addProperty("price", price);
	        request.addProperty("lat", latitude);
	        request.addProperty("lon", longitude);
	        request.addProperty("id", person_id);
	        request.addProperty("type", type);
	        request.addProperty("status", status);
	        request.addProperty("image", image);
	        request.addProperty("property_id", property_id);
	        request.addProperty("sold_date", sold_date);
	        request.addProperty("selling_type", selling_type);

	        //request.addProperty("image", image);

	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_EDITPROPERTY, envelope);
	            return true;

	        } catch (Exception e) {
	            e.printStackTrace();
	            System.out.println("wala ne sud dri");
	            return false;
	        }
			
	    }
	    
	    public boolean addAmmenties(String url,int id,String description) {


	        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_ADDAMMENITIES);

	        request.addProperty("url", url);
	        request.addProperty("property_id", id);
	        request.addProperty("description",description);
	       
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_ADDAMMENITIES, envelope);
	            return true;

	        } catch (Exception e) {
	            e.printStackTrace();
	            System.out.println("wala ne sud dri");
	            return false;
	        }
			
	    }
	    
	    public boolean addPanorama(String url,int id) {
	    	
	        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_ADDPANORAMA);
	        request.addProperty("url", url);
	        request.addProperty("property_id", id);
	       
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_ADDPANORAMA, envelope);
	            return true;

	        } catch (Exception e) {
	            e.printStackTrace();
	            System.out.println("wala ne sud dri");
	            return false;
	        }
			
	    }


	    public int GetId(String uname) {
	        int id = 0;
	        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETID);

	        request.addProperty("username", uname);


	        //request.addProperty("image", image);

	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_GETID, envelope);
	            // Get the SoapResult from the envelope body.
	            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();

	            if (response != null) {
	                String res = response.toString();
	                return id = Integer.parseInt(res);

	            } else {
	                System.out.println("No Response");
	            }


	        } catch (Exception e) {
	            e.printStackTrace();
	            System.out.println("wala ne sud dri");
	        }
	        return id;
	    }

	    public boolean AddLead(String fname, String lname,
	            String mobile,
	            String landline,
	            String email,
	            int property_id,
	            String username,
	            String password,
	            String url) {


	        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_LEAD);

	        request.addProperty("fname", fname);
	        request.addProperty("lname", lname);
	        request.addProperty("mobile", mobile);
	        request.addProperty("landline", landline);
	        request.addProperty("email", email);
	        request.addProperty("id", property_id);
	        request.addProperty("username", username);
	        request.addProperty("password", password);
	        request.addProperty("image", url);
	       // request.addProperty("id", property_id);

	        //request.addProperty("image", image);

	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_LEAD, envelope);


	        } catch (Exception e) {
	            e.printStackTrace();
	            System.out.println("wala ne sud dri SA LEAD");
	            return false;
	        }
	        return true;
	    }
	    public boolean EditLead(String fname, String lname,
	            String mobile,
	            String landline,
	            String email,
	            int property_id,
	            String username,
	            String password,
	            String url) {


	        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_EDITLEAD);

	        request.addProperty("fname", fname);
	        request.addProperty("lname", lname);
	        request.addProperty("mobile", mobile);
	        request.addProperty("landline", landline);
	        request.addProperty("email", email);
	        request.addProperty("id", property_id);
	        request.addProperty("username", username);
	        request.addProperty("password", password);
	        request.addProperty("image", url);

	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_EDITLEAD, envelope);


	        } catch (Exception e) {
	            e.printStackTrace();
	            System.out.println("wala ne sud dri SA LEAD");
	            return false;
	        }
	        return true;
	    }
	    
	    public boolean SaveLead(int property_id,int lead_id) {
	    	
	        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_SAVELEAD);

	        request.addProperty("property_id", property_id);
	        request.addProperty("lead_id", lead_id);
	 
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_SAVELEAD, envelope);


	        } catch (Exception e) {
	            e.printStackTrace();
	            System.out.println("wala ne sud dri NE SAVE LEAD");
	        }
	        return true;
	    }

	    public String getAllPerson() {
	    	String res=null;
	    	
	    	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_ALLPERSON);
	    	
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_ALLPERSON, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	            if(response!=null){
	            	res=response.toString();
	            }

	        } catch (Exception e) {
	            e.printStackTrace();
	            System.out.println("wala ne sud dri SA LEAD");
	        }
	        return res;
	    }
	    
	    public String getAllProperty() {
	    	String res=null;
	    	
	    	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_ALLPROPERTY);
	    		    	
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_ALLPROPERTY, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	            if(response!=null){
	            	res=response.toString();
	            }

	        } catch (Exception e) {
	            e.printStackTrace();
	          //  System.out.println("wala ne sud dri SA LEAD");
	        }
	        return res;
	    }
	    
	    public String getAllPropertyById(int id) {
	    	String res=null;
	    	
	    	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_ALLPROPERTY);
	    		    	
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_ALLPROPERTY, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	            if(response!=null){
	            	res=response.toString();
	            }

	        } catch (Exception e) {
	            e.printStackTrace();
	          //  System.out.println("wala ne sud dri SA LEAD");
	        }
	        return res;
	    }
	    public String getSoldProperty() {
	    	String res=null;
	    	
	    	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETSOLDPROPERTY);
	    		    	
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            
	            androidHttpTransport.call(SOAP_ACTION_GETSOLDPROPERTY, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	            if(response!=null){
	            	res=response.toString();
	            }

	        } catch (Exception e) {
	            e.printStackTrace();
	          
	        }
	        return res;
	    }
	    
	    public String getAgentProperty(int id) {
	    	
	    	String res=null;
	    	
	    	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETAGENTPROPERTY);
	    	request.addProperty("id", id);
	    		    	
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_GETAGENTPROPERTY, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	            if(response!=null){
	            	res=response.toString();
	            }

	        } catch (Exception e) {
	            e.printStackTrace();
	          //  System.out.println("wala ne sud dri SA LEAD");
	        }
	        return res;
	    }
	    
	    public String getLeadProperty(int id) {
	    	
	    	String res=null;
	    	
	    	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETLEADPROPERTY);
	    	request.addProperty("id", id);
	    		    	
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_GETLEADPROPERTY, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	            if(response!=null){
	            	res=response.toString();
	            }

	        } catch (Exception e) {
	            e.printStackTrace();
	          //  System.out.println("wala ne sud dri SA LEAD");
	        }
	        return res;
	    }
	    
	    public String getAgentLead(int id) {
	    	
	    	String res=null;
	    	
	    	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETAGENTLEAD);
	    	request.addProperty("id", id);
	    		    	
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_GETAGENTLEAD, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	            if(response!=null){
	            	res=response.toString();
	            }

	        } catch (Exception e) {
	            e.printStackTrace();
	          //  System.out.println("wala ne sud dri SA LEAD");
	        }
	        return res;
	    }
	    public String getAmmenities(int id) {
	    	
	    	String res=null;
	    	
	    	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETAMMENITIES);
	    	request.addProperty("id", id);
	    		    	
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_GETAMMENITIES, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	            if(response!=null){
	            	res=response.toString();
	            }

	        } catch (Exception e) {
	            e.printStackTrace();
	          //  System.out.println("wala ne sud dri SA LEAD");
	        }
	        return res;
	    }
	    
   public String getpanorama(int id) {
	    	
	    	String res=null;
	    	
	    	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETPANORAMA);
	    	request.addProperty("id", id);
	    		    	
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_GETPANORAMA, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	            if(response!=null){
	            	res=response.toString();
	            }

	        } catch (Exception e) {
	            e.printStackTrace();
	          //  System.out.println("wala ne sud dri SA LEAD");
	        }
	        return res;
	    }
	    public String getMyAccount(int id) {
	    	
	    	String res=null;
	    	
	    	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETMYACCOUNT);
	    	request.addProperty("id", id);
	    		    	
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_GETMYACCOUNT, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	            if(response!=null){
	            	res=response.toString();
	            }

	        } catch (Exception e) {
	            e.printStackTrace();
	          //  System.out.println("wala ne sud dri SA LEAD");
	        }
	        return res;
	    }
	    
	    public String getGraphdata(int year) {
	    	
	    	String res=null;
	    	
	    	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETGRAPHDATA);
	    	request.addProperty("year", year);
	    		    	
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_GETGRAPHDATA, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	            if(response!=null){
	            	res=response.toString();
	            }

	        } catch (Exception e) {
	            e.printStackTrace();
	          //  System.out.println("wala ne sud dri SA LEAD");
	        }
	        return res;
	    }
	    
	    public String MultiCriteriaSearch(String address,String price,String limit,String type) {
	    	
	    	String res=null;
	    	
	    	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_SEARCH);
	    	request.addProperty("address", address);
	    	request.addProperty("price", price);
	    	request.addProperty("limit", limit);
	    	request.addProperty("type", type);
	    		    	
	        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	        envelope.setOutputSoapObject(request);

	        try {

	            HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
	            //this is the actual part that will call the webservice
	            androidHttpTransport.call(SOAP_ACTION_SEARCH, envelope);
	            
	            SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
	            if(response!=null){
	            	res=response.toString();
	            }

	        } catch (Exception e) {
	            e.printStackTrace();
	          //  System.out.println("wala ne sud dri SA LEAD");
	        }
	        return res;
	    }

public String getPropertyBySellingType(String type) {
	
	String res=null;
	
	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETPROPERTYBYSELLINGTYPE);
	request.addProperty("type", type);
		    	
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);

    try {

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        //this is the actual part that will call the webservice
        androidHttpTransport.call(SOAP_ACTION_GETPROPERTYBYSELLINGTYPE, envelope);
        
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        if(response!=null){
        	res=response.toString();
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return res;
}

public String MultiCriteriaSearch2(String address,double price,String type) {
	
	String res=null;
	
	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_SEARCH);
	request.addProperty("address", address);
	request.addProperty("price", price);
	request.addProperty("type", type);
		    	
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);

    try {

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        //this is the actual part that will call the webservice
        androidHttpTransport.call(SOAP_ACTION_SEARCH, envelope);
        
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        if(response!=null){
        	res=response.toString();
        }

    } catch (Exception e) {
        e.printStackTrace();
      //  System.out.println("wala ne sud dri SA LEAD");
    }
    return res;
}

public String ALLPriceSearch(String price){
	String res=null;
	
	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETSEARCHPRICE);

	request.addProperty("price", price);
		    	
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);

    try {

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        //this is the actual part that will call the webservice
        androidHttpTransport.call(SOAP_ACTION_GETSEARCHPRICE, envelope);
        
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        if(response!=null){
        	res=response.toString();
        }

    } catch (Exception e) {
        e.printStackTrace();
      //  System.out.println("wala ne sud dri SA LEAD");
    }
    return res;
}

public String ALLAddressSearch(String address){
	String res=null;
	
	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETSEARCHADDRESS);

	request.addProperty("address", address);
		    	
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);

    try {

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        //this is the actual part that will call the webservice
        androidHttpTransport.call(SOAP_ACTION_GETSEARCHADDRESS, envelope);
        
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        if(response!=null){
        	res=response.toString();
        }

    } catch (Exception e) {
        e.printStackTrace();
      //  System.out.println("wala ne sud dri SA LEAD");
    }
    return res;
}

public String AllTypeSearch(String type){
	String res=null;
	
	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETSEARCH);

	request.addProperty("type", type);
		    	
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);

    try {

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        //this is the actual part that will call the webservice
        androidHttpTransport.call(SOAP_ACTION_GETSEARCH, envelope);
        
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        if(response!=null){
        	res=response.toString();
        }

    } catch (Exception e) {
        e.printStackTrace();
      //  System.out.println("wala ne sud dri SA LEAD");
    }
    return res;
}



public String executeCategorySearch(String address, String price, String type){
	String res=null;
	
	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETSEARCHCATEGORY);

	request.addProperty("address", address);
	request.addProperty("price", price);
	request.addProperty("type", type);
		    	
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);

    try {

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        //this is the actual part that will call the webservice
        androidHttpTransport.call(SOAP_ACTION_GETSEARCHCATEGORY, envelope);
        
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        if(response!=null){
        	res=response.toString();
        }

    } catch (Exception e) {
        e.printStackTrace();
      //  System.out.println("wala ne sud dri SA LEAD");
    }
    return res;
}

public String AddressPriceSearch(String address, String price){
	String res=null;
	
	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETSEARCHADDRESSANDPRICE);

	request.addProperty("address", address);
	request.addProperty("price", price);	    	
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);

    try {

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        //this is the actual part that will call the webservice
        androidHttpTransport.call(SOAP_ACTION_GETSEARCHADDRESSANDPRICE, envelope);
        
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        if(response!=null){
        	res=response.toString();
        }

    } catch (Exception e) {
        e.printStackTrace();
      //  System.out.println("wala ne sud dri SA LEAD");
    }
    return res;
}

public String AddressTypeSearch(String address, String type){
	String res=null;
	
	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETSEARCHADDRESSANDTYPE);

	request.addProperty("address", address);
	request.addProperty("type", type);	    	
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);

    try {

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        //this is the actual part that will call the webservice
        androidHttpTransport.call(SOAP_ACTION_GETSEARCHADDRESSANDTYPE, envelope);
        
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        if(response!=null){
        	res=response.toString();
        }

    } catch (Exception e) {
        e.printStackTrace();
      //  System.out.println("wala ne sud dri SA LEAD");
    }
    return res;
}

public String PriceTypeSearch(String price, String type){
	String res=null;
	
	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETSEARCHPRICEANDTYPE);

	request.addProperty("price", price);
	request.addProperty("type", type);	    	
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);

    try {

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        //this is the actual part that will call the webservice
        androidHttpTransport.call(SOAP_ACTION_GETSEARCHPRICEANDTYPE, envelope);
        
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        if(response!=null){
        	res=response.toString();
        }

    } catch (Exception e) {
        e.printStackTrace();
      //  System.out.println("wala ne sud dri SA LEAD");
    }
    return res;
}

public String getPropertyById(int id){
	String res=null;
	
	SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_GETALLPROPERTYBYID);

	request.addProperty("property_id", id);
	    	
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);

    try {
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        //this is the actual part that will call the webservice
        androidHttpTransport.call(SOAP_ACTION_GETALLPROPERTYBYID, envelope);
        
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        if(response!=null){
        	res=response.toString();
        }

    } catch (Exception e) {
        e.printStackTrace();
      //  System.out.println("wala ne sud dri SA LEAD");
    }
    return res;
}
}
